<template>
  <div>
    <div class="demo-input-suffix gl_searchBox">
      <el-row :gutter="20">
        <el-col :md="2" :lg="4">
          <p>申报名称</p>
          <el-input v-model="Api_GET_ClubDuanExamRequestQO.Filter" placeholder="请输入申报名称" size="mini" clearable @change="gettablelist()" />
        </el-col>
        <el-col :md="2" :lg="4">
          <p>申报机构</p>
          <el-input v-model="Api_GET_ClubDuanExamRequestQO.OrganizationUnitNameFilter" placeholder="请输入申报机构" size="mini" clearable @change="gettablelist()" />
        </el-col>
        <el-col :md="2" :lg="4">
          <p>考试地点</p>
          <el-input v-model="Api_GET_ClubDuanExamRequestQO.AddressFilter" placeholder="请输入考试地点" size="mini" clearable @change="gettablelist()" />
        </el-col>
        <!-- <el-col :md="2" :lg="4">
          <p>申报人</p>
          <el-input v-model="Api_GET_ClubDuanExamRequestQO.ContactFilter" placeholder="请输入申报人" size="mini" clearable @change="gettablelist()" />
        </el-col> -->
        <el-col :md="2" :lg="4">
          <p>申报状态</p>
          <el-select v-model="IsType" size="mini" @change="gettablelist()">
            <el-option label="全部" value="" />
            <el-option label="待审核" value="Pending" />
            <el-option label="审核通过" value="Approved" />
            <el-option label="审核失败" value="NotApproved" />
          </el-select>
        </el-col>
        <el-col :span="5">
          <p>申报时间</p>
          <el-date-picker
            v-model="freeData"
            size="mini"
            style="width: 100%"
            type="daterange"
            range-separator="至"
            start-placeholder="申报开始日期"
            end-placeholder="申报结束日期"
            value-format="yyyy-MM-dd"
            @change="changeAttendance"
          />
        </el-col>
        <el-col :md="4" :lg="4">
          <el-button type="primary" style="margin-top:25px" size="mini" @click="gettablelist()">筛选</el-button>
          <el-button type="warning" size="mini" @click="reset()">{{ $t('button.Reset') }}</el-button>
        </el-col>
      </el-row>
    </div>

    <div style="margin-top:15px">

      <el-table v-loading="tableLoading" class="gl_table_noBorder" size="mini" :data="tableData">
        <el-table-column label="序号" type="index" align="center" width="55" />
        <el-table-column label="申报名称" prop="name" min-width="200" />
        <el-table-column label="申报机构" prop="organizationUnitName" min-width="200" />
        <el-table-column label="考试地点" prop="address" min-width="120" />
        <el-table-column label="申报时间" align="center" prop="name" width="135">
          <template slot-scope="{ row }">
            <span v-if="row.submissionTime">
              {{ row.submissionTime | FormatDate('yyyy-MM-dd HH:mm:ss') }}
            </span>
          </template>
        </el-table-column>
        <el-table-column label="申报状态" align="center" width="120">
          <template slot-scope="{row}">
            <span v-for="item in dict.duanExamRequestStatus" :key="item.code">{{ item.code == row.requestStatusCode ? item.value : '' }}</span>
          </template>
        </el-table-column>
        <el-table-column label="操作" width="80">
          <template slot-scope="{ row }">
            <el-button size="mini" type="text" @click="topersonal(row)">查看详情</el-button>
          </template>
        </el-table-column>
      </el-table>
    </div>
    <el-row class="gl_pt_15" style="text-align: right;">
      <el-pagination
        :current-page="Api_GET_ClubDuanExamRequestQO.Page"
        :page-size="Api_GET_ClubDuanExamRequestQO.MaxResultCount"
        :total="totalPage"
        layout="total,sizes,prev,pager,next,jumper"
        :page-sizes="[10, 20, 30, 40]"
        @size-change="sizeChange"
        @current-change="pageIndexChange"
      />
    </el-row>
  </div>
</template>

<script>
import { mapState, mapActions } from 'vuex';
import { api_GET_ClubDuanExamRequest } from '@/extend/api/hallswaggerApi/app.js';
import { Api_GET_ClubDuanExamRequestQO } from '@/lib/form/hall/swaggerForm';
export default {
  data() {
    return {
      tableLoading: false,
      freeData: [],
      tableData: [],
      IsEnabled: '', // 申报结果
      IsType: '', // 申报状态
      totalPage: 0,

      Api_GET_ClubDuanExamRequestQO: new Api_GET_ClubDuanExamRequestQO() // 成绩审核列表
    };
  },
  computed: {
    ...mapState({
      dict: state => state.dict.dict,
      user: state => state.user.currentOU
    })
  },
  created() {
    this.getDict();
    this.gettablelist();
  },
  methods: {
    ...mapActions({ getDict: 'dict/getDict', getDictByType: 'dict/getDictByType' }),
    // 获取申报审核列表
    gettablelist(page) {
      this.tableLoading = true;
      this.Api_GET_ClubDuanExamRequestQO.RequestStatusCodes = [];
      if (this.IsType !== '') {
        this.Api_GET_ClubDuanExamRequestQO.RequestStatusCodes = [this.IsType];
      } else {
        this.Api_GET_ClubDuanExamRequestQO.RequestStatusCodes = ['Pending', 'Approved', 'NotApproved'];
      }
      this.Api_GET_ClubDuanExamRequestQO.ToOrganizationUnitId = this.user;
      this.Api_GET_ClubDuanExamRequestQO.Sorting = 'creationTime DESC';
      this.Api_GET_ClubDuanExamRequestQO.Page = page || 1;
      this.Api_GET_ClubDuanExamRequestQO.SkipCount = (this.Api_GET_ClubDuanExamRequestQO.Page - 1) * this.Api_GET_ClubDuanExamRequestQO.MaxResultCount;
      api_GET_ClubDuanExamRequest(this.Api_GET_ClubDuanExamRequestQO).then(res => {
        console.log(res);
        this.totalPage = res.totalCount;
        this.tableData = res.items;
        this.tableLoading = false;
      }, error => {
        this.tableLoading = false;
        const _msg = error.error.message || error.message;
        this.$message({ type: 'error', message: _msg });
      });
    },
    // 切换考试日期
    changeAttendance (val) {
      this.Api_GET_ClubDuanExamRequestQO.MinSubmissionTime = val ? val[0] + ' 00:00:00' : null;
      this.Api_GET_ClubDuanExamRequestQO.MaxSubmissionTime = val ? val[1] + ' 23:59:59' : null;
      this.gettablelist();
    },
    // 查看详情
    topersonal(row) {
      this.$router.push({ name: 'Checkdetail', query: { id: row.id }});
    },
    // 分页按钮
    sizeChange(MaxResultCount) {
      this.Api_GET_ClubDuanExamRequestQO.MaxResultCount = MaxResultCount;
      this.gettablelist();
    },
    pageIndexChange(currentPage) {
      this.gettablelist(currentPage);
    },
    // 重置按钮
    reset () {
      this.freeData = [];
      this.IsType = '';
      this.Api_GET_ClubDuanExamRequestQO = new Api_GET_ClubDuanExamRequestQO();
      this.gettablelist();
    }
  }

};
</script>

<style>

</style>
